/* ---------------------------------Marlin Toolkit-----------------------------*
Authors : Daniel Randle, Alex Bourne
Date Created : Feb 20 2013

File:
	debug.h

Description:
	This file contains the declaration for the debug class along with any
	helper functions associated with the class
*-----------------------------------------------------------------------------*/

#ifndef DEBUG_H
#define DEBUG_H

// Inlcudes
#include <logfile.h>
#include <qstring.h>

// Class Forward Declarations
namespace ToolkitGui
{
	class DebugWindow;
}
using namespace ToolkitGui;

/*------------------------------Class Debug----------------------------------*
Description:
	The debug class links a simple output (print) function to a widget in qt so
	that from anywhere in the toolkit we can output to the debug window. The 
	view widget itself will be owned and managed by the Toolkit class but
	the debug class is responsible for all information that goes to the window.
	
	This class also manages a debug logfile which it will output all text to
	by default. You can switch modes between outputing to the debug view only,
	the logfile only, or both. By default it will output to both. This will
	make it possible to reread debug output after the program has ended.

	One last note - there will be a clear screen button on the debug view
	but that does not mean it clears the debug logfile.
*-----------------------------------------------------------------------------*/

class Debug
{
public:
	typedef LogFile::WriteMode LogWriteMode;
	enum OutMode { LogAndDisplay, Display, Log };

	// Ctors
	Debug(DebugWindow * dDisplay, const QString & logFileName = "debug.log");
	Debug(const QString & logFileName = "debug.log");

	// Dtors
	~Debug();

	// Get
	const QString & getLogFileName() const;
	const QString & getLogDirectory() const;
	LogWriteMode getLogWriteMode() const;
	bool isLogTimeStamp() const;
	DebugWindow * getDebugWindow() const;
	OutMode getOutputMode() const;
	bool isAutCls() const;

	// Set
	void setLogFileName(const QString & fileName);
	void setLogDirectory(const QString & directory);
	void setLogWriteMode(LogWriteMode mode);
	void setLogTimeStamp(bool enabled);
	void setDebugWindow ( DebugWindow * dDisplay );
	bool setOutputMode(OutMode m);
	void setAutCls(bool enabled);

	// Functionality
	bool print(const QString & text);
	bool print(const QString & message, float num);
	void cls();

private:
	DebugWindow * display;
	LogFile log;
	bool autoCls;
	OutMode mode;
};

#endif // DEBUG_H